// nuxt.config.ts
export default defineNuxtConfig({
    app: {
        head: {
            link: [
                {
                    rel: 'icon',
                    type: 'image/x-icon',
                    href: 'favicon.ico'
                }
            ],
            meta: [
                {
                    name: 'viewport',
                    hid: 'viewport',
                    content: 'width=device-width, initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0, user-scalable=no'
                },
                {
                    name: 'content-language',
                    hid: 'content-language',
                    content: 'zh-cn',
                },
            ],
        }
    },
    // 添加开发服务器代理配置
    /*nitro: {
        devProxy: {
            '/api': {
                target: 'http://localhost:5050', // 你的 Spring Boot 后端地址
                changeOrigin: true,
                prependPath: true,
                secure: false
            }
        }
    },*/
    nitro: {
        devProxy: {
            '/api': {
                target: 'http://localhost:5050',
                changeOrigin: true,
                ws: true, // 启用 WebSocket 支持
                headers: {
                    Connection: 'keep-alive'
                }
            }
        }
    },

    // 修改运行时配置
    runtimeConfig: {
        public: {
            apiBase: process.env.NODE_ENV === 'production'
                ? '/api'
                : 'http://localhost:5050/api',
            wsBase: process.env.NODE_ENV === 'production'
                ? 'ws://localhost:5050'
                : 'ws://localhost:5050'
        }
    },

    // 现有的模块配置
    modules: [
        '@nuxtjs/tailwindcss',
        '@pinia/nuxt',
        '@pinia-plugin-persistedstate/nuxt',
        '@nuxtjs/google-fonts',
        "vue3-carousel-nuxt",
        "@nuxt/image",
        '@formkit/auto-animate/nuxt',
        "@nuxt/ui",
        '@element-plus/nuxt',
        // 添加 DaisyUI 支持（如果需要）
        // 'daisyui'
    ],

    // 其他现有配置保持不变
    devtools: { enabled: true },
    plugins: [],
    autoAnimate: {
        default: true,
    },
    tailwindcss: {
        exposeConfig: true,
        viewer: true,
        // 添加 DaisyUI 配置（如果需要）
        config: {
            plugins: [
                // require('daisyui')
            ],
            // daisyui: {
            //     themes: ['light', 'dark'],
            // }
        }
    },
    image: {
        dir: 'assets/images',
        presets: {
            cover: {
                modifiers: {
                    fit: 'cover',
                    format: 'jpg',
                    width: 300,
                    height: 300,
                },
            },
        },
    },
    buildModules: ["nuxt-hero-icons"],
    googleFonts: {
        families: {
            'Noto Sans SC': [200, 400, 600, 800],
            'Noto Serif SC': true,
        },
        download: true,
        base64: false,
        overwriting: false,
        outputDir: 'assets/fonts'
    },
    build: {
        transpile: ['@vuepic/vue-datepicker'],
        terser: true,
        splitChunks: {
            layouts: true,
            pages: true,
            commons: true
        }
    },

    // 修改 vite 配置
    vite: {
        server: {
            proxy: {
                '/api': {
                    target: 'http://localhost:5050',
                    changeOrigin: true,
                    ws: true,
                    secure: false,
                    headers: {
                        Connection: 'keep-alive'
                    }
                }
            },
            hmr: {
                protocol: 'ws'
            }
        }
    },
})